feat(frontend): idempotency keys, request validation, Lighthouse budget, Statistics (#1340 #1341 #1349 #1351) - #1463
Open
chideraisiguzor wants to merge 5 commits into
Conversation
|
@chideraisiguzor Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Four issues from the PredictIQ frontend rebuild backlog, all in the
frontendpackage.src/lib/api/idempotency.tsgenerates a UUIDIdempotency-Keyper logical submission, resolved once outside the retry loop so automatic retries reuse it and each new submission gets a fresh one.placeBet/newsletterSubscribeopt in.src/lib/api/requestSchemas.tsholds.loose()Zod schemas mirroring the generated OpenAPI request bodies (compile-time__contractties them tocomponents['schemas']).request()runssafeParsebefore fetch and throwsApiError(..., 'CLIENT_VALIDATION_ERROR')locally instead of letting the server 400.performance/config/thresholds.json; new pureevaluateMetricBudgets()inscripts/lighthouse-audit.js; the script now audits the landing route explicitly, writeslighthouse-latest.json, and exits non-zero when any category is below threshold or any metric is over budget.src/components/Statistics.tsxrecreated on the shareduseAsync(status/retry) contract; data-driven tiles for Total Markets / Total Volume / Active Markets / Resolved Markets, every value coerced throughtoNumber()(number, decimal string, or absent ->0, never blank).src/app/statistics/page.tsxminimally adapted to the same contract.Full per-issue write-up:
frontend/docs/pr/chideraisiguzor-1340-1341-1349-1351.md.Type of Change
Testing Done
From
frontend/:New suites:
idempotency.test.ts(key reused across a 429-then-200 retry, stateful deduping-backend mock),request-validation.test.ts(malformed body rejected locally withfetchnever called),lighthouse-audit.test.js(LCP/CLS over budget fails, missing metric fails), and the rewrittenStatistics.test.tsx(real mocked/api/v1/statisticspayload + an all-zero response asserting every tile renders0/$0).Pre-existing breakage, not touched:
mainis mid-migration to the newuseAsynccontract -tsc --noEmitreports ~351 errors, mostly other consumers still on the old{ loading, execute }API. Only the two files named in #1351 are fixed here (count drops 360 -> 351, no new errors in touched files).LandingPage.accessibility.test.tsxalso has 6 unrelated failing assertions. Left for their own issues per the contribution guidance.Bundle Size
No dependency added (Zod is already a direct dependency).
lighthouse/chrome-launcherare now lazyrequires, so they no longer load unless the audit script actually runs. Runtime component/client changes are small; not separately measured.Checklist
Related Issues
Closes #1340
Closes #1341
Closes #1349
Closes #1351